//
//  CPHomeNewMessageCell.swift
//  cockpit
//
//  Created by Haijun Si on 2020/7/9.
//  Copyright © 2020 chenganrt. All rights reserved.
//

import UIKit

class CPHomeNewMessageCell: UITableViewCell {

    var titleString:String? {
        didSet {
            self.titleLabel.text = titleString ?? ""
        }
    }
    
    var timeString:String? {
        didSet {
            self.timeLabel.text = timeString ?? ""
        }
    }
    
    private let titleLabel = UILabel().then { (label) in
        label.textColor = CPColor666
        label.font = CPFont(font: 14)
        label.numberOfLines = 0
        
    }
    
    private let timeLabel = UILabel().then { (label) in
        label.textColor = CPColor999
        label.font = CPFont(font: 12)
        label.numberOfLines = 1
        label.textAlignment = NSTextAlignment.right
    }
    
   
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
        
        self.addSubview(self.titleLabel)
        self.addSubview(self.timeLabel)
        self.addLine(top: false, color: CPColor_lineColor, lineWidth: CPScreenWidth - 30)
        self.titleLabel.snp.makeConstraints { (make) in
            make.left.equalTo(15)
            make.right.equalTo(-15)
            make.top.equalTo(10)
        }
        
        self.timeLabel.snp.makeConstraints { (make) in
            make.left.equalTo(15)
            make.right.equalTo(-15)
            make.top.equalTo(self.titleLabel.snp_bottom).offset(8)
            make.bottom.equalTo(-10)
        }
    }
    
    func bind(viewModel:CPHomeNewMessageModel) {
        
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}

extension CPHomeNewMessageCell: JFCCellProtocol {
    func configCell(viewModel: Any) {
        if let vm = viewModel as? CPHomeNewMessageModel {
            bind(viewModel: vm)
        }
    }
}
